﻿using CatUtils.Utils.Currency;
using CatUtils.Utils.Currency.IoUtils;
using CatUtils.Utils.SpecialUtils.Html;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace SinaImgUpload.SinaUpload.LocalTool
{
    /// <summary>
    /// 此方法用于处理bedinfo文件，目前已经过时 将在未来某个版本移除
    /// </summary>
    internal class SainListHelper
    {
        /// <summary>
        /// 导出图床列表 从文件夹
        /// </summary>
        /// <param name="BedFloderPath"></param>
        public void ExportBedXmlFloderToList(String BedFloderPath)
        {
            List<string> FoloderList = FloderNameHelper.GetFullFileNameList(BedFloderPath, "*.lst");

            foreach (string line in FoloderList)
            {
                Console.WriteLine(line);
                ExportBedXmlToList(line);
            }
        }

        /// <summary>
        /// 导出图床列表列表
        /// </summary>
        /// <param name="BedFilePath"></param>
        public void ExportBedXmlToList(String BedFilePath)
        {
            List<string> imgInfos = HtmlHelper.GetHtmlValueList(FileHelper.ReadAllText(BedFilePath), "//bed");
            string NewFilePath = FileNameHelper.CreateFileNameWithChildFloder(BedFilePath, "转换为Lst");
            int CompltedCount = 0;
            foreach (string Single in imgInfos)
            {
                new PrintLog().PercentLog(imgInfos.Count, ++CompltedCount);
                FileHelper.AppendText(NewFilePath, HtmlHelper.GetFirstText(Single, "//sina"));
            }
        }
    }
}